import getThemeColor from '@/utils/themesColor'

const imgListData = {
  AFS: '\ue60f',
  ODF: '\ue60d',
  TRANSPORT: '\ue836',
  LIGHT_SPLIT: '\ue60e'
}
// 多主题颜色获取
const colorData = {
  normal: getThemeColor('topoColor') || '#409EFF',
  damage: getThemeColor('topoDamage') || 'red',
  highLight: getThemeColor('topoHighLight') || '#4DC86F',
  alwaysHighLight: getThemeColor('alwaysHighLight') || '#12f10f'
}

// 组装站点显示信息
const formatNodes = (data, type) => {
  return data.map(i => {
    // 默认是站点
    // 设备通过设备类型和类别显示图标
    let iconCode = '\ue603'
    if (type === 'device') {
      if (i.type === 'CLUSTER') {
        iconCode = '\ue611'
      } else {
        iconCode = imgListData[i.nodeCategory] || iconCode
      }
    } else {
      if (i.nodeType === 'AOCC') {
        iconCode = '\ue651'
      }
    }
    const color = i.status === 'DAMAGE' ? colorData.damage : colorData.normal
    return {
      ...i,
      icon: {
        face: 'iconfont',
        code: iconCode,
        weight: 700,
        size: 50, // 50,
        color: color
      },
      font: {
        color: color
      },
      physics: false // false-节点可拖拽 true-节点不会移动
    }
  })
}

// 组装连接线显示信息
const formatEdges = (data) => {
  return data.map(i => {
    const color = i.status === 'DAMAGE' ? colorData.damage : colorData.normal
    return {
      ...i,
      color: {
        color: color
      },
      font: {
        color: color,
        size: 0
      }
    }
  })
}

export {
  formatNodes,
  formatEdges,
  colorData
}
